import request from '../utils/User_Request'

export function login(username, password) {
    const data = {
        username,
        password
    }
    return request({
        url: '/login',
        method: 'post',
        data: data
    })
}
export function getInfo() {
    return request({
        url: '/user/getInfo',
        method: 'get'
    })
}
export function getUsers() {
    return request({
        url: '/user/getUsers',
        method: 'get',
    })
}
export function addUser(user) {
    return request({
        url: '/user/add',
        method: 'post',
        data:user,
    })
}
// 特权指令
export function deleteUser(username) {
    return request({
        url: `/user/delete/${username}`,
        method: 'delete',
    })
}
// 非特权指令
export function updateUser(username, user) {

    return request({
        url: `/user/update/${username}`,
        method: 'put',
        data: user,
    })
}
// 非特权指令
export function resetPassword(username) {
    return request({
        url: `/user/${username}/password`,
        method: 'put',
    })
}
export function getRoles() {
    return request({
        url: '/role/getRoles',
        method: 'get',
    })
}
export function deleteRole(id) {
    return request({
        url: '/user/login',
        method: 'post',
    })
}
export function addRole(rolename, role) {
    return request({
        url: `/role/add/${rolename}`,
        method: 'put',
        data: role,
    })
}
export function updateRole(rolename, role) {
    return request({
        url: `/role/update/${rolename}`,
        method: 'put',
        data: role,
    })
}


